import i18n from "@/i18n";

export const usernameValid = [
    {
        required: true,
        message: i18n.t('regedit.username_valid_fail'),
        trigger: ['blur', 'change'],
        pattern: /^[\w-]{4,16}$/
    }
];

export const passwordValid = [
    {
        required: true,
        message: i18n.t('regedit.password_valid_fail'),
        trigger: ['blur', 'change'],
        pattern: /^\S*(?=\S{8,})(?=\S*\d)(?=\S*[A-Z])(?=\S*[a-z])(?=\S*[!@#$%^&*? ])\S*$/
    }
]

export const lengthvalid_0_16 = [
    {
        min: 0,
        max: 16,
        message: i18n.t('regedit.length_valid_over'),
        trigger: ['blur', 'change'],
    }
]

export const phoneValid = [
    {
        required: true,
        message: i18n.t('regedit.phone_valid_fail'),
        trigger: ['blur', 'change'],
        pattern: /^(?:(?:\+|00)86)?1[3-9]\d{9}$/
    }
]

export const emailValid = [
    {
        required: true,
        message: i18n.t('regedit.email_valid_fail'),
        trigger: ['blur', 'change'],
        pattern: /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
    }
]

export const numberValid = [{
    type: 'number', 
    message: i18n.t('regedit.number_valid_fail')
}]

export const authCodeValid = [
    {
        required: true,
        message: i18n.t('regidit.captcha_not_empty'),
        trigger: ['blur', 'change']
    },{
        len: 4,
        message: i18n.t('regidit.captcha_over_length'),
        trigger: 'blur'
    }
]